Skip to content

Use FormDocumentResource model within Form model#2028

Open
stephencdaly wants to merge 4 commits intomainfrom
firebreak-make-form-plain-model-with-delegation
Open

Use FormDocumentResource model within Form model#2028
stephencdaly wants to merge 4 commits intomainfrom
firebreak-make-form-plain-model-with-delegation

Conversation

@stephencdaly
Copy link
Copy Markdown
Contributor

What problem does this pull request solve?

Trello card: https://trello.com/c/02H0xEqG

Previously, the Form model was an ActiveResource model that was constructed using the JSON retrieved from the forms-admin API using the FormDocumentResource model.

Make it a plain Ruby object and instead delegate attributes to the FormDocumentResource model. This means we are not using the ActiveResource model directly in the rest of the codebase, and instead consuming the Form model which has a defined interface. Future changes to the API can be handled more easily within the Form model.

Things to consider when reviewing

  • Ensure that you consider the wider context.
  • Does it work when run on your machine?
  • Is it clear what the code is doing?
  • Do the commit messages explain why the changes were made?
  • Are there all the unit tests needed?
  • Do the end to end tests need updating before these changes will pass?
  • Has all relevant documentation been updated?

@stephencdaly stephencdaly force-pushed the firebreak-make-form-plain-model-with-delegation branch 2 times, most recently from 93769eb to 936a271 Compare April 8, 2026 11:50
@stephencdaly stephencdaly marked this pull request as ready for review April 8, 2026 12:07
Previously, the Form model was an ActiveResource model that was
constructed using the JSON retrieved from the forms-admin API using
the FormDocumentResource model.

Make it a plain Ruby object and instead delegate attributes to
the FormDocumentResource model. This means we are not using the
ActiveResource model directly in the rest of the codebase, and instead
consuming the Form model which has a defined interface. Future
changes to the API can be handled more easily within the Form model.

As part of this change, remove the code that expects that the API
response can include an `id` attribute rather than `form_id` as this
will no longer be the case.
The question mark on the trait doesn't make sense.
@stephencdaly stephencdaly force-pushed the firebreak-make-form-plain-model-with-delegation branch from 936a271 to 33adc28 Compare April 8, 2026 13:44
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

🎉 A review copy of this PR has been deployed! You can reach it at: https://pr-2028.submit.review.forms.service.gov.uk/

It may take 5 minutes or so for the application to be fully deployed and working. If it still isn't ready
after 5 minutes, there may be something wrong with the ECS task. You will need to go to the integration AWS account
to debug, or otherwise ask an infrastructure person.

For the sign in details and more information, see the review apps wiki page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants